import React from 'react'
// ===================================================================== Temp
import SearchForm from '#cpt/temp/SearchForm'
import Table from '#cpt/temp/Table'
// ===================================================================== Declare
const { $fn, $Lazy } = window
// ===================================================================== Lazy
const Page = $Lazy.load(()=>import('#tp/page/page-container'))
// 
const recordStatus = [{ name:'出库', value:'-1' },{ name:'入库', value:'0' }]
// ===================================================================== component
class Index extends React.Component{
	state = {
		data:[],
		pag: {},
		// 搜索表单列表
		forms : [
			{ label: '条码号',		name: 'spec_code' },
			{ label: '实验号',		name: 'experiment_num' },
			{ label: '操作时间',		names: ['start_at','end_at'], 	type:'date-range', 	loading:true },
		],
	}
		
	componentDidMount(){
		if(window.isInit){
			this.fetch()
		}
	}
	
	// paging
	fetch = () => $fn.fetch.call(this,'sp-container-item/record')
	
	// 表单
	cols = [
		{ title: '条码号', 		dataIndex: 'spec_code', 		...$fn.table.spec_code },
		{ title: '实验号', 		dataIndex: 'experiment_num', 	...$fn.table.spec_code },
		// { title: '行', 			dataIndex: 'rows', 				width:80 },
		// { title: '列', 			dataIndex: 'column', 			width:80 },
		{ title: '操作人', 		dataIndex: 'operate_user', 		...$fn.table.name },
		{ title: '操作时间', 	dataIndex: 'create_at',  		...$fn.table.time},
		{ title: '条码状态', 	dataIndex: 'type', 				...$fn.table.status,	render: text => $fn.getState(recordStatus,text) },
	]
	
	render(){
		return (
			<Page title='出入库记录'>
				{/* 搜索 */}
				{ SearchForm.call(this) }
				{/* 表格 */}
				{ Table.call(this, {isInit: window.isInit}) }
			</Page>
		)
	}
}

export default Index